package com.rp.system.po;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.raptor.entity.BaseModel3;

/**
 * 系统资源
 * @author HuangJian
 *
 */
@Entity
@Table(name="RP_SYSTEM_RESOURCES")
public class Resource extends BaseModel3 {

	private static final long serialVersionUID = 410913280964864346L;
	
	private String url;			//资源链接
	private String name;		//资源名称
	private String type;		//类型：暂时没什么用处
	private String remark;		//备注
	private String pingtai;		//是否是平台资源
	
	private List<Authority> authorities = new ArrayList<Authority>();
	
	private String moduleId;
	private String moduleName;
	
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	public String getPingtai() {
		return pingtai;
	}
	public void setPingtai(String pingtai) {
		this.pingtai = pingtai;
	}
	
	@JsonIgnore
	@ManyToMany(mappedBy="resources", fetch = FetchType.LAZY)
	public List<Authority> getAuthorities() {
		return authorities;
	}
	public void setAuthorities(List<Authority> authorities) {
		this.authorities = authorities;
	}
	
	public String getModuleId() {
		return moduleId;
	}
	public void setModuleId(String moduleId) {
		this.moduleId = moduleId;
	}
	public String getModuleName() {
		return moduleName;
	}
	public void setModuleName(String moduleName) {
		this.moduleName = moduleName;
	}
	
	/**
	 * 重写equals方法
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Resource) {
			Resource resource = (Resource) obj;
			if (resource.getId().equals(this.getId())) {
				return true;
			}
		}
		return false;
	}
	
	
}
